package kr.hkit.powerjava.chapter10;

import java.util.*;
import java.util.*;

public class LottoGenerater2 {
	private boolean[] lotto;
	private Random rnd;
	private static final int SIZE = 6;

	public LottoGenerater2() {
		lotto = new boolean[45];
		rnd = new Random();
	}

	public void getLottoNums(int cnt) {
		for (int i = 0; i < cnt; i++) {
			getLottoNum();
		}

	}

	public void initLotto() {
		for (int i = 0; i < lotto.length; i++) {
			lotto[i] = false;
		}
	}

	public void getLottoNum() {
		int num = -1;
		for (int i = 0; i < SIZE; i++) {
			num = rnd.nextInt(45);
			if (lotto[num]) { // 중복된값이존재
				i--;
			} else {
				lotto[num] = true;
			}
		}
	}

	public void prnLottoNum() {
		for (int i = 0; i < lotto.length; i++) {
			if (lotto[i]) {
				System.out.printf("%3d", i + 1);
			}
		}
	}
}